/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Painel.java
 *
 * Created on 29/06/2010, 10:45:04
 */
package GUI;

import java.awt.Point;

/**
 * @author Thay
 */
public class Painel extends javax.swing.JFrame {

    /** Cria o novo formulario Painel */
    public Painel() {
        
        initComponents();
    }

    /**
     * Este metodo eh chamado no construtor
     * da classe para inicializar o formulario.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel1 = new Desenho2D();
        robo = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Sistema Fuzzy");
        addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                formKeyPressed(evt);
            }
        });

        jScrollPane1.setPreferredSize(new java.awt.Dimension(2000, 2000));

        jPanel1.setBackground(new java.awt.Color(254, 254, 254));
        jPanel1.setBorder(null);
        jPanel1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jPanel1MouseClicked(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(254, 254, 254));
        jPanel1.setBorder(null);

        robo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/wally.jpg"))); // NOI18N
        robo.setMaximumSize(new java.awt.Dimension(50, 50));
        robo.setMinimumSize(new java.awt.Dimension(50, 50));
        robo.setPreferredSize(new java.awt.Dimension(50, 50));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(robo, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(1935, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(robo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(1917, Short.MAX_VALUE))
        );

        jScrollPane1.setViewportView(jPanel1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 500, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(66, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 473, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>

    private void formKeyPressed(java.awt.event.KeyEvent evt) {
        // TODO add your handling code here:

        
        tecla = evt.getKeyCode();

        switch (tecla)
        {
            case 37:    // Seta para a DIREITA
                robo.setLocation(
                        new Point(robo.getLocation().x - 10, robo.getLocation().y));
                break;
            case 38:    // Seta para CIMA
                robo.setLocation(
                        new Point(robo.getLocation().x, robo.getLocation().y - 10));
                break;
            case 39:    // Seta para a ESQUERDA
                robo.setLocation(
                        new Point(robo.getLocation().x + 10, robo.getLocation().y));
                break;
            case 40:    // Seta para BAIXO
                robo.setLocation(
                        new Point(robo.getLocation().x, robo.getLocation().y + 10));
                break;
        }
    }

    private void jPanel1MouseClicked(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
        
        jPanel1.desenhaObstaculo(evt.getPoint());
    }
    
    // Declaracao das variaveis;
    private javax.swing.JLabel robo;
    private Desenho2D jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private int tecla;
    // Fim da declaracao de variaveis;
}
